<?php
/**
 * Created by PhpStorm.
 * User: jungshen
 * Date: 2018/10/24
 * Time: 13:46
 */

namespace app\api\controller\other;

use think\Controller;
use think\Db;
use think\Exception;

class City extends Controller
{
    /**
     * @author jungshen
     * 获取城市列表
     * @param pid 上级id default:0
     * @return \think\response\Json
     */
    public function lists(){
        try{
            $pid=input('pid',0);
            //获取城市列表
            $list=Db::name('system_city')->where('pid',$pid)->where('status',1)->field('id,name')->select();
            return json(['msg'=>'success','data'=>$list],200);
        }catch (Exception $e){
            return json(['msg'=>$e->getMessage()],500);
        }
    }
}